﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Windows;
using System.Windows.Controls;

namespace SharePointCommander.Model.TreeView
{
    public class SCListCollection : SCTreeViewItem<SPListCollection>
    {
        public SCListCollection(SCTreeViewItem parent, SPListCollection lists)
            : base(parent, lists)
        {
            Header = "Lists";
            IsExpanded = false;
            Expanded += new RoutedEventHandler(SCListCollection_Expanded);
            ItemsSource = new object[] { null };
        }

        void SCListCollection_Expanded(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;
            if (item.ItemsSource.Cast<object>().Contains(null))
            {
                item.ItemsSource = from SPList l in SPObject select new SCList(this, l);
            }
        }
    }
}
